home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 January / PSL Monthly Shareware CD-ROM (Public Software Library) (January 1994).iso / games / dos / ascii_ga / berserk.com / BERSERK.BAS < prev    next >
Encoding:
BASIC Source File  |  1988-01-17  |  11.2 KB  |  318 lines

  1. 1 'save "BERSERK.BAS",a ' berserk game like meteor
  2. 2 DEFINT A-Z:KEY OFF:CLS:LOCATE ,,0
  3. 3 DIM CRASHER(10,5),BULLET(10,4),BERSERKER$(12),BFREE(11),SCORES(11),SCORES$(11)
  4. 4 PRINT "BERSERK! by Keith P. Graham":print "Do you need Instructions";
  5. 5 Y$=""
  6. 6 WHILE Y$<> "Y" AND Y$ <> "y" AND Y$<> "N" AND Y$<> "n"
  7. 7    INPUT Y$
  8. 8 WEND
  9. 9 IF Y$="N" OR Y$="n" GOTO 400 
  10. 10 CLS
  11. 11 PRINT "The year is 2086 and you are a private in the Astro-Marines."
  12. 12 PRINT "Your assignment is to observe sector 273.425 for Berserker"
  13. 13 PRINT "activity. The Berserkers, a race of machines who want to destroy"
  14. 14 PRINT "humanity, have been releasing gravity bombs towards the Earth."
  15. 15 PRINT "These bombs are really huge asteroids which when aimed at earth"
  16. 16 PRINT "fall slowly towards the planet until striking it and breaking"
  17. 17 PRINT "the earth into a thousand pieces. The bombs are accompanied"
  18. 18 PRINT "by a terrible meteorite storm."
  19. 20 PRINT "You must watch for meteors and gravity bombs. If you see them"
  20. 21 PRINT "you may press the firing button (space bar) and shoot at them."
  21. 22 PRINT "Meteors appear as rapidly falling arrows on your screen. If you"
  22. 23 PRINT "hit a meteor you will receive 25 merit points. If you miss the"
  23. 24 PRINT "meteor will hit the earth and kill thousands of people, but since"
  24. 25 PRINT "usually happens in other parts of the world, you only loose one"
  25. 26 PRINT "merit for every time a meteor gets by."
  26. 27 PRINT "If a meteor crashes into you, you loose 50 points."
  27. 28 PRINT "When you see the Berserker bomb appear you must try to"
  28. 30 PRINT "destroy it. It will keep coming until every trace of it"
  29. 31 PRINT "is vapourized by your missiles. If you can do this, you"
  30. 32 PRINT "can win the game."
  31. 34 PRINT "From time to time you may see a berserker observer boat go"
  32. 35 PRINT "by. If you can hit one of those its worth 200 points."
  33. 36 PRINT " "
  34. 37 PRINT "Press return to continue";
  35. 38 INPUT A$
  36. 39 CLS
  37. 400 REM constants
  38. 401 RANDOMIZE  TIMER
  39. 402 CLS
  40. 403 CRASHES=0
  41. 404 SCORE=0
  42. 405 BTIME = 35
  43. 406 CRASHMAX=3
  44. 407 BMAX=7
  45. 408 CTKEY=0
  46. 409 KEYGO$=CHR$(77)+CHR$(75)+CHR$(80)+CHR$(72)+CHR$(27)+CHR$(32)
  47. 410 CTKEYX=0
  48. 413 C$=CHR$(25)
  49. 414 B$=CHR$(24)
  50. 415 ME$=CHR$(178)
  51. 416 MEY=40:MEX=24
  52. 417 BERMAX=10:BINDEX = 1
  53. 418 BSIZE=10
  54. 420 'print "LN";v$;"VF"; 
  55. 421  LOCATE MEX,MEY :PRINT ME$;
  56. 423 FOR M = 1 TO CRASHMAX
  57. 424    GOSUB 30000 ' create crasher M
  58. 425 NEXT M
  59. 426 GOSUB 35000 ' create the berserker
  60. 427 GOSUB 38000 ' create a patrol boat
  61. 428 REM   loop for game
  62. 429 X= 0
  63. 430 WHILE X= 0
  64. 431   GOSUB 10000  ' get a key
  65. 432  FOR M = 1 TO CRASHMAX
  66. 433   GOSUB 20000 ' crasher 
  67. 434  NEXT M
  68. 435  FOR B=1 TO BMAX
  69. 436   GOSUB 55000
  70. 437  NEXT B
  71. 438  GOSUB 25000 'check the berserker
  72. 439  GOSUB 15000 'check the boat
  73. 440   WEND
  74. 441 GOTO 60000 
  75. 10000 REM this routine gets a key and checks to see if its correct
  76. 10001  CTKEY$=INKEY$:IF CTKEY$="" THEN RETURN
  77. 10002    WHILE CTKEY$<>""
  78. 10003    CTKEY=ASC(RIGHT$(CTKEY$,1))
  79. 10004    CTKEY$=INKEY$
  80. 10005    WEND
  81. 10006   GT = INSTR(KEYGO$,CHR$(CTKEY))
  82. 10007   IF GT=0 THEN RETURN
  83. 10008   ON GT GOTO 10100,10200,10300,10400,60000,50000,10009
  84. 10009   RETURN
  85. 10100 REM right key pressed
  86. 10101  LOCATE MEX,MEY :PRINT " "; ' space out the old one
  87. 10102  MEY=MEY+1
  88. 10103  IF MEY > 77 THEN MEY=77
  89. 10104  GOTO  10500
  90. 10200 REM left key pressed
  91. 10201  LOCATE MEX,MEY:PRINT" "; ' space out the old one
  92. 10202  MEY=MEY-1
  93. 10203  IF MEY <1 THEN MEY = 1
  94. 10204  GOTO 10500
  95. 10300 REM down  key pressed
  96. 10301  LOCATE MEX,MEY:PRINT " "; ' space out the old one
  97. 10302  MEX=MEX+1
  98. 10303  IF MEX > 24 THEN MEX=24
  99. 10304  GOTO  10500
  100. 10400 REM up   key pressed
  101. 10401  LOCATE MEX,MEY:PRINT " "; ' space out the old one
  102. 10402  MEX=MEX-1
  103. 10403  IF MEX < 1  THEN MEX=1  
  104. 10404  GOTO  10500
  105. 10500  REM print the me$
  106. 10501  LOCATE MEX,MEY:PRINT ME$;
  107. 10502  GOSUB 40000  ' check for hit
  108. 10503  GOTO 45000  ' check for eat 
  109. 15000 REM check for boat
  110. 15001    IF BOATY=0 THEN RETURN
  111. 15002   LOCATE BOATX,BOATY:PRINT " ";
  112. 15003    BOATY=BOATY+1
  113. 15004    IF BOATY > 77 THEN BOATY = 0:RETURN
  114. 15005   LOCATE BOATX,BOATY:PRINT CHR$(&HA4);
  115. 15006    RETURN
  116. 15007    RETURN
  117. 20000 REM move the crasher
  118. 20001   ' m has the crasher
  119. 20002  LOCATE CRASHER(M,1),CRASHER(M,2):PRINT " ";
  120. 20003    CRASHER(M,1)=CRASHER(M,1)+CRASHER(M,3)
  121. 20004    IF CRASHER(M,1)>23 THEN GOSUB 30000:SCORE=SCORE - 1:RETURN
  122. 20005    CRASHER(M,2)=CRASHER(M,2)+CRASHER(M,4)
  123. 20006    IF CRASHER(M,2)>77 THEN CRASHER(M,2)=1
  124. 20007    IF CRASHER(M,2)<1 THEN CRASHER(M,2)=77
  125. 20008    LOCATE CRASHER(M,1),CRASHER(M,2):PRINT C$;
  126. 20009   M1=M
  127. 20010   GOTO 40050
  128. 25000 REM move the berserker
  129. 25001    ON PHASE GOTO 25100,26000,25100,27000,25100
  130. 25100 BCOUNT = BCOUNT+1
  131. 25101    IF BCOUNT > BTIME THEN PHASE = PHASE + 1:BCOUNT = 0
  132. 25102    RETURN
  133. 26000 REM move the beserker down a line
  134. 26001    PHASE = 1
  135. 26002    BLINE=BLINE+1   ' bline is the bottom line of ther berserker
  136. 26003    ELINE=BLINE-BSIZE  ' eline is the top line of the beserker
  137. 26005 BP = BERMAX+1-BSIZE  ' first line of berserker
  138. 26006    IF BLINE <1 GOTO 26010
  139. 26007    IF BERSERKER$(BP)<>SPACE$(LEN(BERSERKER$(BP))) GOTO 26010
  140. 26008    BSIZE= BSIZE - 1 :BLINE=BLINE-1 
  141. 26009    IF BSIZE < 1 THEN GOTO 27000 
  142. 26010 REM
  143. 26011    REM print each of the lines of the beserker
  144. 26012    IF BLINE=24 GOTO 60000
  145. 26013    IF ELINE<1 THEN ELINE=1
  146. 26014    IF ELINE<>1 AND BOATY=0 THEN BOATY = 1
  147. 26015 '   print "AA";
  148. 26016    IF ELINE<>0 THEN LOCATE ELINE,1:PRINT SPACE$(77);
  149. 26017    FOR B=ELINE TO BLINE
  150. 26018    ' calculate bottom line
  151. 26019     BINDEX= (BLINE-B)+1+(BERMAX-BSIZE)
  152. 26020    IF B=24 AND BERSERKER$(BINDEX-1)<>SPACE$(42) GOTO 60000
  153. 26021    IF B < 25 THEN LOCATE B,20:PRINT BERSERKER$(BINDEX);
  154. 26022    NEXT B 
  155. 26023  REM check to see if we have been eaten by a beserker
  156. 26024    GOTO 45000
  157. 27000 'end game
  158. 27001 PRINT "LF";V$;"VN";
  159. 27002 CLS
  160. 27003    PRINT " I hate to say this, but you may have won this game"
  161. 27004    GOSUB 59000
  162. 27005  LOCATE 2,7
  163. 27006    PRINT "Enter you initials (3 characters) "; 
  164. 27007    INTI$=""
  165. 27008    INPUT INIT$
  166. 27009    PRINT
  167. 27010    OPEN "A",1,"bscores"
  168. 27011    WRITE #1,"  ",-9999
  169. 27012    CLOSE #1
  170. 27013    OPEN "I",1,"bscores"
  171. 27014    FOR J = 1 TO 10
  172. 27015   IF NOT EOF(1) THEN INPUT #1,SCORES$(J)
  173. 27016   IF NOT EOF(1) THEN INPUT #1,SCORES(J)
  174. 27017    NEXT J
  175. 27018    CLOSE #1
  176. 27019    OPEN "O",1,"bscores"
  177. 27020    FOR J = 1 TO 10
  178. 27021   IF SCORES(J) < SCORE THEN SCORES(J)=SCORE:SCORES$(J)=INIT$:GOTO 27900 
  179. 27022    NEXT J
  180. 27900 FOR J = 1 TO 10
  181. 27901    WRITE #1,SCORES$(J),SCORES(J)
  182. 27902    PRINT SCORES$(J),SCORES(J)
  183. 27903    NEXT J
  184. 27904    CLOSE #1
  185. 27906    GOTO 60010
  186. 27907    RETURN 
  187. 30000 REM create a crasher
  188. 30001    ' m has the crasher number
  189. 30002    ' the crashers always start on row past the beserker
  190. 30003   IF BLINE<24 THEN CRASHER(M,1)=BLINE+1 ELSE CRASHER(M,1)=24
  191. 30004    ' they can start on any column from 1 to 77
  192. 30005   CRASHER(M,2)=INT(RND*77)+1
  193. 30006    ' they can have a horizontal speed from -4 to +4
  194. 30007   CRASHER(M,4)=4 - INT(RND*9)
  195. 30008    ' they can have a verticle speed from 1 to 3
  196. 30009   CRASHER(M,3)=INT(RND*2)+1
  197. 30010    ' they can have an attribute of A to P (65 to 79) (but not blink or UL)
  198. 30011   CRASHER(M,5)=65+INT(RND*2)+4*INT(RND*2)
  199. 30012   RETURN
  200. 35000 REM init berseker
  201. 35001    ' bottom lline of berserker is berserker$(1)
  202. 35002    FOR B=1 TO BSIZE
  203. 35003    BERSERKER$(B)= STRING$((11-B)*2,32)+STRING$((4*B)-2,176)+STRING$((11-B)*2,32)
  204. 35004    NEXT B
  205. 35005    BLINE=1
  206. 35006    PHASE = 1
  207. 35007    RETURN
  208. 38000 REM create boat
  209. 38001    BOATY=0
  210. 38002    BOATX=1
  211. 38003    RETURN
  212. 40000 REM check to see if the thing is hit
  213. 40001    FOR M1 = 1 TO CRASHMAX
  214. 40002    GOSUB 40050
  215. 40003    NEXT M1
  216. 40004    RETURN
  217. 40050 IF ((MEX<(CRASHER(M1,1)-1)) OR (MEX>(CRASHER(M1,1)+1))) THEN RETURN
  218. 40051    IF ((MEY<(CRASHER(M1,2)-1)) OR (MEY>(CRASHER(M1,2)+1))) THEN RETURN
  219. 40052 REM  the crash
  220. 40053    CRASHES=CRASHES+1
  221. 40054    SCORE= SCORE - 50
  222. 40055    GOSUB 59000
  223. 40056   LOCATE CRASHER(M1,1),CRASHER(M1,2):PRINT " ";
  224. 40057  LOCATE MEX,MEY:PRINT ME$;
  225. 40058    M=M1
  226. 40059   GOTO 30000
  227. 45000 REM beserker check
  228. 45005  ' LOCATE 25,40:PRINT BLINE;MEY;MEX;
  229. 45011   IF MEX>BLINE THEN GOTO 45070 'bline is bottom of beserker
  230. 45012   IF MEY<20 THEN GOTO 45070  ' left and
  231. 45013   IF MEY>60 THEN GOTO 45070  'right of berserker
  232. 45014   ' bsize starts out at 10 and is the size of the berserker
  233. 45015   '    number of lines   first index of berserker - 1
  234. 45016   BINDEX= (BLINE-MEX)   +1+  (BERMAX-BSIZE)
  235. 45017  'IF BINDEX>BMAX GOTO 45070
  236. 45018   BX=MEY-19
  237. 45019   IF MID$(BERSERKER$(BINDEX),BX,1)=" " THEN GOTO 45070
  238. 45020  REM we have been eaten by a beserker
  239. 45021   GOTO 60000
  240. 45070 RETURN
  241. 50000 REM shoot up
  242. 50001    REM find a free bullet
  243. 50002    IF MEX=0 THEN RETURN
  244. 50003    FOR B= 1 TO BMAX
  245. 50004     IF BFREE(B)= 0 THEN GOTO 50100
  246. 50005    NEXT B
  247. 50006    RETURN
  248. 50100 BFREE(B)=1
  249. 50101    BULLET(B,2)=MEY
  250. 50102    BULLET(B,1)=MEX-1
  251. 50103   LOCATE BULLET(B,1),BULLET(B,2):PRINT B$;
  252. 50104    RETURN
  253. 55000 REM move bullets
  254. 55001    IF BFREE(B)=0 THEN RETURN
  255. 55002   LOCATE BULLET(B,1),BULLET(B,2):PRINT " ";
  256. 55003    BULLET(B,1)=BULLET(B,1)-1
  257. 55004    IF BULLET(B,1)<1 THEN BFREE(B)=0:RETURN
  258. 55006   LOCATE BULLET(B,1),BULLET(B,2):PRINT B$;
  259. 55007    GOTO 56000
  260. 56000 FOR M1 = 1 TO CRASHMAX
  261. 56001    IF BULLET(B,1)<CRASHER(M1,1)-1 OR BULLET(B,1)>CRASHER(M1,1)+1 THEN GOTO 56050
  262. 56002    IF BULLET(B,2)<CRASHER(M1,2)-1 OR BULLET(B,2)>CRASHER(M1,2)+1 THEN GOTO 56050
  263. 56003   GOTO 56100
  264. 56050 REM check to see if we hit the boat
  265. 56051    IF BOATY=0 GOTO 56060
  266. 56052    IF BULLET(B,1)>2 THEN GOTO 56060
  267. 56053    IF BULLET(B,2)<BOATY-1 OR BULLET(B,2)>BOATY+1 GOTO 56060
  268. 56054    REM hit the boat!!!!
  269. 56055    SCORE=SCORE + 200
  270. 56056   LOCATE BOATX,BOATY:PRINT " ";
  271. 56057    BOATY=0
  272. 56058    GOTO 59000
  273. 56060 REM check to see if we are hitting beserker
  274. 56061   IF BULLET(B,1)>BLINE THEN GOTO 56080 'bline is bottom of beserker
  275. 56062   IF BULLET(B,2)<20 THEN GOTO 56080  ' left and
  276. 56063   IF BULLET(B,2)>60 THEN GOTO 56080  'right of berserker
  277. 56064   BINDEX= (BLINE-BULLET(B,1))+1+(BERMAX-BSIZE)
  278. 56065   IF BINDEX>BERMAX GOTO 56080
  279. 56066   BX=BULLET(B,2)-19
  280. 56067   IF MID$(BERSERKER$(BINDEX),BX,1)=" " THEN GOTO 56080
  281. 56068   SCORE= SCORE +5
  282. 56069  BFREE(B)=0
  283. 56070   LOCATE CRASHER(M1,1),CRASHER(M1,2):PRINT " ";
  284. 56071  MID$(BERSERKER$(BINDEX),BX,1)=" "
  285. 56072   GOTO 59000
  286. 56080 NEXT M1
  287. 56081    RETURN
  288. 56100 REM hit a crasher, destroy bullet and crasher
  289. 56101   LOCATE CRASHER(M1,1),CRASHER(M1,2):PRINT " ";
  290. 56102   LOCATE BULLET(B,1),BULLET(B,2):PRINT "*";
  291. 56103 SCORE=SCORE+25
  292. 56104  GOSUB 59000
  293. 56105  BFREE(B)=0
  294. 56106  M=M1
  295. 56107  GOSUB 30000
  296. 56108  GOTO 56080
  297. 59000 REM print score
  298. 59001 LOCATE 25,2  :PRINT "score =";SCORE;
  299. 59002 LOCATE 25,30  :PRINT "CRASHES=";CRASHES;
  300. 59003   RETURN
  301. 60000 REM end of program, time to tally score
  302. 60001 'print "LF";v$;"VN";
  303. 60002 CLS:PRINT "You loose, fool."
  304. 60003 PRINT "The beserker bomb has struck, the earth is destroyed"
  305. 60004 GOSUB 59000
  306. 60010 REM wait for key
  307. 60011 FOR J = 1 TO 5000
  308. 60012 NEXT J
  309. 60013 Y$=""
  310. 60014   PRINT "Play again? (Y/N)";
  311. 60015 WHILE Y$<>"Y" AND Y$<>"N"
  312. 60016 Y$=INKEY$
  313. 60017 IF Y$="y" THEN Y$="Y"
  314. 60018 IF Y$="n" THEN Y$="N"
  315. 60019 WEND
  316. 60020 CLS
  317. 60021 IF Y$="Y" GOTO 400
  318.